﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class WebUserControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            Init();
    }
    public void Init()
    {
        ASPxNavBar1.Groups.Clear();
        var menu = DataConnection.LibDB.LIB_SYS_MENU_Get_ParentID(0);
        int index=0;
        foreach (var item in menu)
        {
            ASPxNavBar1.Groups.Add(item.Menu_Name,"grp"+ item.Menu_ID,clsPublic.myURL()+item.Icon.TrimStart('/'),clsPublic.myURL()+ item.VirtualUrl.TrimStart('^').TrimStart('~').TrimStart('/'));
            try
            {
                var submenu = DataConnection.LibDB.LIB_SYS_MENU_Get_ParentID(item.Menu_ID);
                foreach (var subitem in submenu)
                {
                    ASPxNavBar1.Groups[index].Items.Add(subitem.Menu_Name, "subitem" + subitem.Menu_ID, clsPublic.myURL() + subitem.Icon.TrimStart('/'), clsPublic.myURL() + item.VirtualUrl.TrimStart('^').TrimStart('~').TrimStart('/'));
                }
            }
            catch { }
            index++;

        }
    }
}